<?php

namespace App\Models;


use App\Service\Base\Model;

class CourseSign extends Model
{

    // 广告管理
    protected $table = 'course_sign';

    // 缓存字段，用于搜索绑定的字段
    protected $cacheFields = ['id', 'uid', 'course_id', 'student_id'];

    // {"id":"自编号","uid":"用户ID","course_id":"课程id","student_id":"学员ID","course_uid":"用户","status":"状态 0-未到 1-正常 2-请假","is_up":"是否补课（1-是）","ctime":"注册时间","mtime":"更新时间"}


    // array ( 'id' => '$this->getData("id")', 'uid' => '$this->getData("uid")', 'course_id' => '$this->getData("course_id")', 'student_id' => '$this->getData("student_id")', 'course_uid' => '$this->getData("course_uid")', 'status' => '$this->getData("status")', 'is_up' => '$this->getData("is_up")', 'ctime' => '$this->getData("ctime")', 'mtime' => '$this->getData("mtime")', )


    // $id = $this->getData("id"); $uid = $this->getData("uid"); $course_id = $this->getData("course_id"); $student_id = $this->getData("student_id"); $course_uid = $this->getData("course_uid"); $status = $this->getData("status"); $is_up = $this->getData("is_up"); $ctime = $this->getData("ctime"); $mtime = $this->getData("mtime");

    // 支付类型
    public function getStatus($getKey = true)
    {
        $channels = [
            '2' => '请假',
            '1' => '签到',
            '0' => '未到',
        ];

        if(empty($getKey)){
            return $channels;
        }

        return array_keys($channels);
    }

    // 定义验证操作
    public function rules()
    {

        $add = [
        ];

        $edit = [
        ];

        $info = [
        ];


        $rule = [
            'uid'        => 'required',
            'course_id'  => 'required',
            'time_id'    => 'required',
            'student_id' => 'required',
            //'course_uid' => 'required',
            //'up_time'    => 'required',
            //'is_up'      => 'required',
            'status'     => ['in:-1,0,1,2'],
        ];


        $msg = [
            'id'         => '自编号',
            'uid'        => '用户ID',
            'course_id'  => '课程id',
            'time_id'    => '课时id',
            'student_id' => '学员ID',
            'course_uid' => '用户',
            'status'     => '状态 0-未到 1-正常 2-请假 3-补课',
            'up_time'    => '操作时间（请假时间，或者补课时间）',
            'is_up'      => '是否补课（1-是）',
            'ctime'      => '注册时间',
            'mtime'      => '更新时间',
        ];

        return ['rule' => $rule, 'msg' => $msg, 'add' => $add];
    }
}
